package com.hrmsys.dao.impl;

import java.util.List;

import com.hrmsys.bean.PageBean;
import com.hrmsys.dao.LeaveDAO;
import com.hrmsys.model.Department;
import com.hrmsys.model.Leave;

public class LeaveDAOImpl extends BaseDAO implements LeaveDAO {

	@Override
	public PageBean<Leave> findAll(String start, String limit) {
		String hql = "FROM Leave";
		PageBean<Leave> pageBean = new PageBean<>();
		pageBean.setRoot(this.page(hql, Integer.parseInt(start), Integer.parseInt(limit)));
		pageBean.setTotalProperty(this.findTotal(Leave.class));
		return pageBean;
	}

	@Override
	public boolean delete(String[] reIds) {
		boolean flag = true;
		for(String boonId : reIds){
			if(!super.deleteById(Leave.class, Integer.parseInt(boonId))) 
				flag = false;
		}
		return flag;
	}

	@Override
	public boolean saveOrUpdate(Leave boon) {
		if(super.saveOrUpdate(boon)){
			return true;
		}
		return false;
	}

	@Override
	public List<Leave> findAll() {
		return findAll(Leave.class);
	}
	@Override
	public List<Leave> findById(String id) {
		return super.findByProperty(Leave.class,"leaveId",Integer.valueOf(id));
	}


}
